#include "tcpServer.hpp"
#include "daemon.hpp"

#include <memory>
using namespace std;
using namespace Server;
static void Usage(const string &arg)
{
    cout << "\nplease input ./tcpServer local_port\n" << endl;
}
int main(int argc, char* argv[])
{
    cout << getpid() << endl;
    cout << pthread_self() << endl;
    if(argc != 2)
    {
        Usage(argv[0]);
        logMessage(FATAL, "Usage error");
        exit(USAGE_ERR);
    }
    logMessage(NORMAL, "Usage success");
    unique_ptr<TcpServer> ptsv(new TcpServer(atoi(argv[1])));
    ptsv->initServer();
    //daemonSelf();
    ptsv->start();
    return 0;
}
